package com.briup.service.impl;

import com.briup.dao.EmpMapper;
import com.briup.entity.Emp;
import com.briup.service.IEmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class EmpServiceImpl implements IEmpService {
    //dao层对象
    @Autowired
    private EmpMapper empDao;

    @Override
    public Emp getById(Integer id) {
        System.out.println("in service ...");

        Emp emp = empDao.getById(id);

        //处理 gender 1: 男, 2: 女
        Short gender = emp.getGender();
        if(gender != null) {
            if (gender == 1) {
                emp.setGenderStr("男");
            } else if (gender == 2) {
                emp.setGenderStr("女");
            }
        }

        //处理job - 1: 讲师, 2: 班主任 , 3: 就业指导
        Short job = emp.getJob();
        if(job != null){
            if(job == 1){
                emp.setJobStr("讲师");
            }else if(job == 2){
                emp.setJobStr("班主任");
            }else if(job == 3){
                emp.setJobStr("就业指导");
            }
        }

        return emp;
    }
}
